package com.Method;

/***
 * @ClassName: Recursion
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 11:06 2022/1/25
 * @version : V1.0
 */
public class Recursion {

    public static void main(String[] args) {
        int f = f(7);
        System.out.println(f);
        System.out.println(factorial(5));
    }

    //斐波那契数列
    static int f(int i){
        switch (i) {
            case 1:
                return 1;
            case 2:
                return 1;
            default:
                return f(i-1)+f(i-2);
        }
    }


    //阶乘
    static int factorial(int i){
        switch (i) {
            case 1:
                return 1;
            default:
                return factorial(i-1)*i;
        }
    }
}
